﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StockFinder.Model
{
    public class DailyPrice
    {
        public int SymbolId { get; set; }
        public string Symbol { get; set; }
        public decimal High { get; set; }
        public decimal Low { get; set; }
        public decimal Open { get; set; }
        public decimal Close { get; set; }
        public DateTime PriceDate { get; set; }
        public decimal Volume { get; set; }
        public bool IsSet { get; set; }
        public decimal AdjustedClose { get; set; }
        public decimal AdjustedHigh
        {
            get
            {
                decimal adjustedHigh = High;

                //does an adjustment need to be made?
                if (AdjustedClose != Close)
                {
                    //make sure we have these values
                    if (AdjustedClose > 0 && High > 0 && Close > 0)
                    {
                        //find ratio of adjusted close then apply to High
                        adjustedHigh = (AdjustedClose / Close) * High;
                    }
                }

                return adjustedHigh;
            }
        }

        public decimal AdjustedLow
        {
            get
            {
                decimal adjustedLow = Low;

                //does an adjustment need to be made?
                if (AdjustedClose != Close)
                {
                    //make sure we have these values
                    if (AdjustedClose > 0 && Low > 0 && Close > 0)
                    {
                        //find ratio of adjusted close then apply to Low
                        adjustedLow = (AdjustedClose / Close) * Low;
                    }
                }

                return adjustedLow;
            }
        }
        public decimal AdjustedOpen
        {
            get
            {
                decimal adjustedOpen = Open;

                //does an adjustment need to be made?
                if (AdjustedClose != Close)
                {
                    //make sure we have these values
                    if (AdjustedClose > 0 && Open > 0 && Close > 0)
                    {
                        //find ratio of adjusted close then apply to Low
                        adjustedOpen = (AdjustedClose / Close) * Open;
                    }
                }

                return adjustedOpen;
            }
        }

        #region Indicators

        public Dictionary<string, decimal> DayIndicators = new Dictionary<string, decimal>();        

        #endregion
    }
}

